package svc

import (
	"portal/internal/config"
	"portal/internal/middleware"

	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"github.com/zeromicro/go-zero/rest"
)

type ServiceContext struct {
	Config config.Config

	Orm sqlx.SqlConn

	Auth rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,
		Orm: sqlx.NewMysql(c.DB.DataSource),
		Auth: middleware.NewAuthMiddleware(c).Handle,
	}
}
